package com.mysoft.gfyx.demo.controller;

import com.mysoft.gfyx.demo.service.RoomService;
import com.mysoft.gfyx.demo.service.dto.RoomDto;
import com.mysoft.framework.modeling.dataapi.LoadDataApi;
import com.mysoft.framework.modeling.dto.FieldsSetting;
import com.mysoft.framework.modeling.dto.ListDataResult;
import com.mysoft.framework.modeling.dto.LoadDataParams;
import com.mysoft.framework.mvc.api.Controller;
import com.mysoft.framework.rpc.annotation.PubAction;
import com.mysoft.framework.rpc.annotation.PubService;
import com.mysoft.framework.rpc.contants.RequestPrefix;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;

@PubService(value = "/room", prefix = RequestPrefix.API)
@Tag(name = "房间信息-API")
public class RoomController extends Controller implements LoadDataApi {

    @Autowired
    private RoomService roomService;

    @Override
    public boolean projectFilter() {
        return false;
    }

    @Override
    public FieldsSetting loadFields() {
        return roomService.loadFields();
    }

    @Override
    public ListDataResult loadData(@RequestBody LoadDataParams options) {
        return roomService.loadData(options);
    }

    @PubAction(value = "/saveOrUpdate", method = RequestMethod.POST)
    public RoomDto saveOrUpdate(@RequestBody RoomDto dto) {
        return roomService.saveOrUpdate(dto);
    }

    @PubAction(value = "/delete", method = RequestMethod.POST)
    public void deleteById(String id) {
        roomService.deleteById(id);
    }

    @PubAction(value = "/info", method = RequestMethod.POST)
    public RoomDto selectById(String id) {
        return roomService.selectById(id);
    }

}
